<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title><fmt:message code="main.th.feedbackStep" /></title>
    <link rel="stylesheet" href="../../css/workflow/work/m/style.css">
    <style>
        .nofirest {
            height: 44px;
            line-height: 44px;
            padding-left: 15px;
        }
        .l, .r {
            height: 40px;
        }
        .l .circle {
            margin-right: 8px;
            border: none;
        }
        #nextstep{
            padding-left: 0;
        }
        #EWCturn{
            display: none;
            position: fixed;
            bottom: 0;
            left: 0;
            width: calc(100% - 2px);
            height: 50px;
            line-height: 50px;
            text-align: center;
            background: #3c91e4;
            border: 1px solid #3c91e4;
            color: #fff;
        }
    </style>
</head>
<body>
<div class="turnview" id="pro_turn"><div class="word_title">
    <img src="../../img/workflow/m/apply_next_select.png" alt="" class="icon">
    <div class="word_quick_action"><fmt:message code="main.th.feedbackStep" /></div>
</div>
    <div class="list-panel" id="nextstep">

    </div>

    <div id="panel-next-user" style="padding-bottom: 50px">
        <div class="word_title nofirest">
            <img src="../../img/workflow/m/apply_next_select.png" alt="" class="icon">
            <div class="word_quick_action">请输入回退意见：</div>
        </div>
        <div class="signBox">
            <textarea id="feedbacktext" rows="4" class="gapp_textarea" data-key="0" data-field-type="020000" data-must="0" data-is-write="1" name="" placeholder=""></textarea>

        </div>

    </div>
    <div id="EWCturn" onclick="feedback()">確定</div>
    <button id="feedbackbtn" style="display: none;">确定</button>
</div>
<script src="../../js/jquery/jquery-1.9.1.js"></script>
<script src="../../js/template.js"></script>
<script src="../../lib/laydate/laydate.js"></script>
<script src="../../js/mustache.min.js"></script>
<script src="../../js/base/base.js"></script>
<script>

var feedback = {};
//兼容ios个别流程 找不到feedback()方法
function turn(){
    feedback();
}
    $(function () {
        var flowId = $.getQueryString("flowId");
        var flowStep = $.getQueryString("flowStep") || '';
        var prcsId = $.getQueryString("prcsId") || '';
        var runId = $.getQueryString("runId") || '';
        var allowback = $.getQueryString("allowback") || '';
        var tableName = $.getQueryString("tableName") || '';
        var tabId = $.getQueryString("tabId") || '';
        var frpId = $.getQueryString("frpId") || '';
        if($.getQueryString("type") == 'EWC'){
            $('#EWCturn').show();
        }else{
            $('#EWCturn').hide();
        }
            $.ajax({
                type: "get",
                url: "getflowprcsdata",
                dataType: 'JSON',
                data: {
                    prcsId: flowStep,
                    runId: runId,
                    allowBack:allowback
                },
                success: function (res) {

                   if(res.flag){
                       var prcName = '';
                        res.obj.forEach(function (v,i) {
                            <%--prcName +='<span class="nofirest"><input type="radio" flowPrcs="'+v.flowProcess.prcsId+'" nextPrcsId="0" value="normal2" name="feedbackstep" >&nbsp;<fmt:message code="workflow.th.First" />'+v.prcsId+'<fmt:message code="workflow.th.step" />'+v.flowProcess.prcsName+'&nbsp;&nbsp;主办人：'+v.userName+'</span><br>';--%>
                            prcName +='<li class="nofirest" onclick="ajax_info($(this))" flowprcs="'+v.flowProcess.prcsId+'" backId="'+v.id+'"><div class="l"><img src="/img/widget_open.png" uname="" class="circle" type="radio" nextprcsid="0" value="normal2" name="nextstep"></div><div class="r"><span style="margin-left: 0;">&nbsp;<fmt:message code="workflow.th.First" />'+v.prcsId+'<fmt:message code="workflow.th.step" />'+v.flowProcess.prcsName+'&nbsp;&nbsp;主办人：'+v.userName+'</span></div></li>'
                        })
                        $('#nextstep').html(prcName);
                        $('.nofirest').eq(0).click();
                   }
                }
             });

        feedback = function () {
            var backflowPrcs = $(".bag").parents('.nofirest').attr('flowprcs');
            var feedbacktext = $('#feedbacktext').val()
            var backId = $(".bag").parents('.nofirest').attr('backId');
            if(feedbacktext == ''){
                layer.msg("<fmt:message code="main.th.ReturnOpinion" />！");
            }else{


            $.ajax({
                type: "get",
                url: "insertprcsdata",
                dataType: 'JSON',
                data: {
                    id:frpId,
                    backId:backId,
                    flowPrcs : backflowPrcs,
                    prcsId : prcsId,
                    flowStep:flowStep,
                    runId : runId,
                    feedback : feedbacktext,
                    tabId:tabId,
                    tableName:tableName
                },
                success: function (res) {
                    if(res.flag){
                        layer.msg('回退成功！');
                        if($.getQueryString("type") != 'EWC'){
                            /************调用移动端返回工作流列表方法************************/
                            if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
                                try{
                                    window.webkit.messageHandlers.finishWork.postMessage({});
                                }catch(err){
                                    finishWork();
                                }
                            } else if (/(Android)/i.test(navigator.userAgent)) {
                                Android.finishWebActivity();
                            }
                        }else{
                            window.history.go(-2);
                        }


                    }else{
                        layer.msg('回退失败！');
                    }

                }
            });
            }
        };
        $('#feedbackbtn').click(function () {
            feedback();
        });

    });
function ajax_info(a) {
    var e = a.find('.circle');
    e.addClass('bag').attr('src', '/img/widget_check2.png').parents('.nofirest').siblings().find('.circle').removeClass('bag').attr('src', '/img/widget_open.png');
}
</script>
</body>
</html>